# -*- coding: utf-8 -*-
# @Time    : 2022/3/22 14:04
# @Author  : Zhy
# @Email   : mat_wu@163.com
# @File    : user.py
# @Software: PyCharm

from common.models import db
from datetime import datetime


class User(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    account = db.Column(db.String(20), nullable=False, doc='账户')
    name = db.Column(db.String(20), doc='名字')
    password = db.Column(db.String(20), nullable=False, doc='密码')
    last_login_time = db.Column(db.DateTime, doc='最后一次登录时间')
    ctime = db.Column(db.DateTime, doc='创建时间')
    news = db.relationship('News', backref='user')


class News(db.Model):
    __tablename__ = 'news'
    nid = db.Column(db.Integer, primary_key=True, autoincrement=True)
    title = db.Column(db.String(20), doc='标题')
    content = db.Column(db.String(50), doc='内容')
    ctime = db.Column(db.DateTime, doc='创建时间')
    status = db.Column(db.String(10), doc='状态')
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
